<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/common.js"></script>
    <script src="../js/jquery-1.8.3.min.js"></script>
</head>
<body>
    fixList
    <hr>
    <table border="1" id="tab">
        <tr>
            <td>维修人员</td>
            <td>维修住户</td>
            <td>维修原因</td>
            <td>维修状态</td>
            <td>维修申请时间</td>
            <td>维修解决时间</td>
        </tr>
    </table>
</body>
</html>

<script>
    function format1(millisecond){
        time = new Date(millisecond);
        var year = time.getFullYear()+'年';
        var month = time.getMonth()+1+'月';
        var date = time.getDate()+'日';
        return [year,month,date].join('-');
    };

    function format2(millisecond){
        time = new Date(millisecond);
        var hour = time.getHours()+":";
        var minute = time.getMinutes()+":";
        var second = time.getSeconds();
        return format(millisecond)+hour+minute+second;
    };

    $(function () {
        $.ajax({
            url: "fix/findAll",
            type: "get",
            dataType: "json",
            success: function (resp) {
                if(resp.httpCode == 200){
                    console.log("success");
                    var fixList = resp.data;
                    for(var i=0; i<fixList.length; i++){
                        var upTime = format1(fixList[i].upTime);
                        var commitTime = "";
                        if(fixList[i].commitTime != undefined){
                            commitTime = format1(fixList[i].commitTime);
                        }
                        var state = "未修好";
                        if(fixList[i].fixState == 1){
                            state = "已修好";
                        }
                        $("#tab").append(
                            "<tr>" +
                                "<td>"+fixList[i].empId+"</td>"+
                                "<td>"+fixList[i].houseId+"</td>"+
                                "<td>"+fixList[i].fixReason+"</td>"+
                                "<td>"+state+"</td>"+
                                "<td>"+upTime+"</td>"+
                                "<td>"+commitTime+"</td>"+
                            "</tr>"
                        )
                    }
                }
            }
        })
    })


</script>